<%-- 
    Document   : manage
    Created on : Oct 24, 2011, 8:01:07 AM
    Author     : Yudi Retanto
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/header.jsp"></jsp:include>
<h1>
    Manage Flights
</h1>
<script type="text/javascript">
    function changeAirport(){
        city = $('#sAirport').val();
        if(city < 0){
            $('#sPool').load('./flights?action=manage&get=pool&city='+city);
            $('#defCity').remove();
        }        
    }
    $(function() {
        $( "#iDate" ).datepicker({ dateFormat: "yy/mm/dd" });
    });
    function filter(){
        airport=$("#sAirport").val();
        date = $("#iDate").val();
        if(airport < 0){
            alert("Tolong pilih airport keberangkatan");
        } else if(date==""){
            alert("Tolong masukkan tanggal keberangkatan");
        } else {
            date = new Date(date);
            date = date.getTime();
            $('#manageSched').load('./flights?action=manage&get=schedule&airport='+airport+'&date='+date);
        }
        return false;
    }
</script>
<form onsubmit="return filter();">
<table id="manageForm">
    <tr>
        <td style="width: 20%;">
            <label for="name">Airport Keberangkatan :</label>
        </td>
        <td>
            <select id="sAirport" name="airport" onchange="changeAirport();">
                <option id="defAirport" value="-1" selected="selected">Pilih Airport Keberangkatan</option>
                <c:forEach items="${airports}" var="airport">
                    <option value="${airport.getID()}">${airport.getName()}</option>
                </c:forEach>
            </select>
        </td>
    </tr>
    <tr>
        <td style="width: 20%;">
            <label for="name">Tanggal Keberangkatan :</label>
        </td>
        <td>
            <input type="text" name="date" id="iDate"/>
        </td>
    </tr>
    <tr>
        <td>
            <input type="submit" name="submit" value="submit"/>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <table id="manageSched">
                
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <a href="./flights?action=manage&mode=add">Tambah Jadwal</a>
        </td>
    </tr>
</table>
</form>
<jsp:include page="/footer.jsp"></jsp:include>